﻿using Ordering.Domain.SeedWork;

namespace Ordering.Domain.Aggregate
{
    public class Buyer : Entity, IAggregateRoot
    {
        public override string Id { get; }

        public decimal Balance { get; private set; }

        protected Buyer()
        {

        }

        public Buyer(decimal balance)
        {
            Balance = balance;
        }

        public void UpdateBalace(decimal amount)
        {
            if (amount < 0 && Math.Abs(amount) > Balance)
            {
                throw new DomainException("余额不足");
            }
            Balance += amount;
        }
    }
}
